/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package com.zhifei.common.utils;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
@Data
public class Result<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 编码：200表示成功，其他值表示失败
     */
    @ApiModelProperty(value = "编码：200表示成功，其他值表示失败")
    private String retcode;
    /**
     * 消息内容
     */
    @ApiModelProperty(value = "消息内容")
    private String retmsg;
    /**
     * 响应数据
     */
    @ApiModelProperty(value = "响应数据")
    private T data;

    private Result(String retcode, String retmsg, T data) {
        this.retcode = retcode;
        this.retmsg = retmsg;
        this.data = data;
    }

    private Result(String retcode, String retmsg) {
        this.retcode = retcode;
        this.retmsg = retmsg;
    }

    public static Result success(Object data) {
        return new Result("0000", "success", data);
    }

    public static Result success() {
        return new Result("0000", "success");
    }

    public static Result success(String msg) {
        return new Result("0000", msg);
    }


    public static Result error(String msg) {
        return new Result("500", msg);
    }


}
